<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../template/WorkspaceTemplate.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="top">
        
    </ui:define>

    <ui:define name="left">
       
    </ui:define>

    <ui:define name="right">
       
    </ui:define>

    <ui:define name="content">
        <h:form>
            <p:panel>
                <p:messages showDetail="true"/>
                <p:panel header="Announcement Details">
                    <h:panelGrid columns="3">
                        <h:outputLabel value="Title: *"/>
                        <p:inputText id="ATitle" value="#{annouceManagerBean.selectedAnnouncement.title}"
                                     required="true" requiredMessage="Title is compulsory"/>
                        <p:message for="ATitle"/>

                        <h:outputLabel value="Posted By"/>
                        <h:outputText value="#{workspaceManagerBean.currentStaff.fullName}"/>
                        <h:outputText value=""/>

                        <h:outputLabel value="Posted On"/>
                        <h:outputText value="#{annouceManagerBean.selectedAnnouncement.formattedDate}"/>
                        <h:outputText value=""/>
                    </h:panelGrid>
                </p:panel>

                <p:panel header="Annoucement contents">
                    <p:editor widgetVar="contentEdit" value="#{annouceManagerBean.selectedAnnouncement.content}"
                              required="true" requiredMessage="Announcement content is compulsory."/>
                </p:panel>

                <p:dataTable value="#{annouceManagerBean.allRoles}" var="role" selection="#{annouceManagerBean.selectedAnnRoles}"
                             style="width: 100%"
                             paginator="true" rows="5"  
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                             rowsPerPageTemplate="5,10,15">
                    <f:facet name="header">
                        Roles that can view the announcement
                    </f:facet>

                    <p:column selectionMode="multiple" />

                    <p:column headerText="Role name"
                              filterBy="#{role.roleName}">
                        <h:outputText value="#{role.roleName}"/>
                    </p:column>

                    <p:column headerText="Department"
                              filterBy="#{role.department}">
                        <h:outputText value="#{role.department}"/>
                    </p:column>
                </p:dataTable>
                <p:commandButton value="Save" ajax="false" action="#{annouceManagerBean.saveEdition}"/>
                <p:commandButton value="Back" onclick="javascript: history.go(-1)"/>
            </p:panel>
            <p:ajaxStatus style="width: 16px;height: 16px;">
                <f:facet name="start">
                    <h:graphicImage value="./../images/ajaxloading.gif"/>
                </f:facet>
                <f:facet name="complete">
                    <h:outputText value=""/>
                </f:facet>
            </p:ajaxStatus>
        </h:form>
    </ui:define>

    <ui:define name="bottom">
       
    </ui:define>

</ui:composition>
